package api

import (
	"github.com/gin-gonic/gin"
	"todolist/pkg/e"
	"todolist/pkg/utils"
	"todolist/service"
)

func UserRegister(c *gin.Context) {
	var userRegisterService service.UserService
	if err := c.ShouldBind(&userRegisterService); err == nil {
		res := userRegisterService.Register()
		c.JSON(e.SUCCESS, res)
	} else {
		c.JSON(e.InvalidParams, ErrorResponse(err))
		utils.LogrusObj.Info(err)
	}
}

func UserLogin(c *gin.Context) {
	var userLoginService service.UserService
	if err := c.ShouldBind(&userLoginService); err == nil {
		res := userLoginService.Login()
		c.JSON(e.SUCCESS, res)
	} else {
		c.JSON(e.InvalidParams, ErrorResponse(err))
		utils.LogrusObj.Info(err)
	}
}
